Salesperson assignment submission#13
Salesperson assignment submission#13codeblahblah wants to merge 16 commits intoRubyoffRails:masterfrom
Conversation
|
@jwo Created a separate file for the Benchmarking named salesperson_bm.rb |
|
@jwo The route distance calculation is working however I am "losing" the original city schedule after the CalculateRoute#route invocation. |
|
@jwo It seems the |
|
I haven't looked into this fully, but yes, Witness another example: word = "Sheep"
word.gsub!("ee", "o")
=> "Shop"
puts word
"Shop"
word = "Sheep"
word.gsub("ee", "o")
=> "Shop"
puts word
"Sheep"You'll see this all over ruby. |
|
@jwo Gotcha! |
|
@jwo Some questions... Can the starting point method be refactored or simplified? Anytime I see an IF stament in a 'each' loop, I perceive it to be a good smell? When would you use variables versus a Hash for object initialization e.g. Benchmarking code: RSpec: How would you convert 28.83 hours to a more readable human format? Are there any Gems for such? When does one decide to go use a Gem versus hack their own solution? |
|
This does seem very complicated. I recommend you rewrite into english, and have the methods do those things. cities.each_index do |index|
cities.insert(0, cities.delete_at(index)) if cities[index].starting_point == true
endIf you are looking to have the cities without the starting point, this could be useful: cites.reject{|c| c.starting_point} |
You probably mean "code smell", which is bad. I agree. |
Good Guidline to follow: You can send 0, 1, or 2 variables to any method, including initialization. Any more than that, use a hash. |
|
For converting 28.83 hours -- check out these: |
|
BTW, code overall is really good |
|
This will make your tests pass: You could tell this because the failure message told you: |
|
@jwo Thanks for the feedback and encouragement. Side note: I'm working on the Gem assignment and get a load path error when On Wednesday, March 5, 2014, Jesse Wolgamott notifications@github.com
"When you are tired of being yourself then you can be ordinary." - dudu |
|
"about-drammopo" -- means You want the second. As far as "jeweler" -- not used much anymore. |
|
@ jwo I'm stuck here: Using your This is the code: But I get a NilClass error below: |
|
It's probably best to isolate the problem; it can illuminate issues that seem hard to find. The error you entered looks like it has a nil in the array - can you prove/disprove this? On Mon, Mar 10, 2014 at 2:35 PM, drammopo notifications@github.com
|
|
@jwo Isolating the problem worked! I wrote it down in simplified English and it became clearer. Pity you cannot multiple assign arrays thus my: |
|
AWESOME! unrouted_cities << city unless unrouted_cities.include?(city)
cities << city unless cities.include?(city)Well, let's see what we can do. If we want to send an item into two arrays, maybe we could: [unrouted_cities, cities].each{|a| a << city} unless cities.include?(city)That might read better... what do you think? |
|
@jwo GREAT! |
@jwo Completed the Panda Level.
Had to comment out the tests below as they used stubs:
Pending:
SalesPerson should have many cities
# Temporarily disabled with xit
# ./spec/sales_person_spec.rb:7
SalesPerson should keep the cities only scheduled once
# Temporarily disabled with xit
# ./spec/sales_person_spec.rb:13
Is this approach correct?
New code: